package com.ayq.activiti.systemweb.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 视图
 *
 */
@Api(tags = "流程管理视图")
@Controller
@RequestMapping("/activitiManager")
@Slf4j
public class ActivitiManagerController {

    @RequestMapping(value = "/deploymentIndex", method = RequestMethod.GET)
    @RequiresPermissions("activiti:activitiManager:deploymentIndex:index")
    public String getListDeploymentHtml() {
        return "activiti/deploymentList";
    }

    /**
     * <p>跳转模型列表页面</p>
     * <p>方法名:getListHtml</p>
     *
     * @Author ayq
     * @Date 2021/3/10 14:57
     * @Param []
     * @Return java.lang.String
     */
    @RequestMapping(value = "/modelList", method = RequestMethod.GET)
    @RequiresPermissions("activiti:activitiManager:modelList:index")
    public String getListHtml() {
        return "activiti/list";
    }


    @RequestMapping(value = "/activitiVersion", method = RequestMethod.GET)
    public String getActivitiVersionHtml(String key, org.springframework.ui.Model model) {
        model.addAttribute("key", key);
        return "activiti/activitiVersion";
    }

    /**
     * <p>根据部署ID查看流程信息</p>
     * <p>方法名:getDeploymentIdBpmnXml</p>
     *
     * @Author ayq
     * @Date 2021/3/25 17:55
     * @Param [deploymentId, resourceName, model]
     * @Return java.lang.String
     */
    @ApiOperation(value = "根据部署ID查看流程信息", notes = "根据部署ID查看流程信息")
    @RequestMapping(value = "/getDeploymentIdBpmnXml/{deploymentId}", method = RequestMethod.GET)
    public String getDeploymentIdBpmnXml(@PathVariable("deploymentId") String deploymentId, String resourceName, Model model) {
        model.addAttribute("deploymentId",deploymentId);
        model.addAttribute("resourceName",resourceName);
        return "activiti/bpmn";
    }

    @ApiOperation(value = "获取表单设计器", notes = "获取表单设计器")
    @RequestMapping(value = "/getFormDesigner", method = RequestMethod.GET)
    public String getFormDesigner() {
        return "form/index";
    }

}
